<template>
  <div class="delivery-append-modal">
    <modal-temp ref="modal" @confirm="confirm" modal-name="新增送货单">
      <template #btn>
        <a-button size="large" type="primary" class="green-btn btn">
        <a-icon type="plus" />
          新增送货单
        </a-button>
      </template>
      <template #content>
        <a-alert class="alert" v-if="error" message="请选择一个客户" banner closable/>
        <client-select ref="select"></client-select>
      </template>
    </modal-temp>
  </div>
</template>

<script>
import ModalTemp from './ModalTemp';
import ClientSelect from '@/components/select/ClientSelect';

export default {
  name: "DeliveryAppendModal",
  props: {

  },
  data() {
    return {
      error: false
    };
  },
  computed: {

  },
  mounted() {

  },
  watch: {

  },
  methods: {
    confirm() {
      const clientId = this.$refs.select.value
      if (clientId == '') {
        this.error = true;
        setTimeout(() => {
          this.error = false;
        }, 100000);
      }
      else {
        this.$router.push({
          name: 'DeliveryAppend',
          params: {
            clientId
          }
        })
        this.$refs.modal.visible = false;
      }
    }
  },
  components: {
    ModalTemp,
    ClientSelect
  },
};
</script>

<style scoped lang="scss">
.delivery-append-modal {
}
</style>
